const router = require('koa-router')()
const areas = require('../models/areas.js')


router.prefix('/api/areas')
router.get('/', async (ctx, next) => {
  ctx.body = await areas.getArea();
}
  )
router.post('/', async (ctx, next) => {
  const { areaName } = ctx.request.body;
  ctx.body = await areas.addArea(areaName);
})

router.put('/:id', async (ctx, next) => {
  ctx.body = await areas.updateArea();
})
router.delete('/:id', async (ctx, next) => {
  ctx.body = await areas.delArea();
})

module.exports = router
